package com.ruoyi.fireRescueRank.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fireRescueRank.domain.IfmFireRescueRank;
import com.ruoyi.fireRescueRank.service.IIfmFireRescueRankService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消防救援衔Controller
 * 
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/fireRescueRank/fireRescueRank")
public class IfmFireRescueRankController extends BaseController
{
    @Autowired
    private IIfmFireRescueRankService ifmFireRescueRankService;

    /**
     * 查询消防救援衔列表
     */
    @PreAuthorize("@ss.hasPermi('fireRescueRank:fireRescueRank:list')")
    @GetMapping("/list")
    public TableDataInfo list(IfmFireRescueRank ifmFireRescueRank)
    {
        startPage();
        List<IfmFireRescueRank> list = ifmFireRescueRankService.selectIfmFireRescueRankList(ifmFireRescueRank);
        return getDataTable(list);
    }

    /**
     * 导出消防救援衔列表
     */
    @PreAuthorize("@ss.hasPermi('fireRescueRank:fireRescueRank:export')")
    @Log(title = "消防救援衔", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IfmFireRescueRank ifmFireRescueRank)
    {
        List<IfmFireRescueRank> list = ifmFireRescueRankService.selectIfmFireRescueRankList(ifmFireRescueRank);
        ExcelUtil<IfmFireRescueRank> util = new ExcelUtil<IfmFireRescueRank>(IfmFireRescueRank.class);
        util.exportExcel(response, list, "消防救援衔数据");
    }

    /**
     * 获取消防救援衔详细信息
     */
    @PreAuthorize("@ss.hasPermi('fireRescueRank:fireRescueRank:query')")
    @GetMapping(value = "/{rescueRankId}")
    public AjaxResult getInfo(@PathVariable("rescueRankId") Long rescueRankId)
    {
        return success(ifmFireRescueRankService.selectIfmFireRescueRankByRescueRankId(rescueRankId));
    }

    /**
     * 新增消防救援衔
     */
    @PreAuthorize("@ss.hasPermi('fireRescueRank:fireRescueRank:add')")
    @Log(title = "消防救援衔", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IfmFireRescueRank ifmFireRescueRank)
    {
        return toAjax(ifmFireRescueRankService.insertIfmFireRescueRank(ifmFireRescueRank));
    }

    /**
     * 修改消防救援衔
     */
    @PreAuthorize("@ss.hasPermi('fireRescueRank:fireRescueRank:edit')")
    @Log(title = "消防救援衔", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IfmFireRescueRank ifmFireRescueRank)
    {
        return toAjax(ifmFireRescueRankService.updateIfmFireRescueRank(ifmFireRescueRank));
    }

    /**
     * 删除消防救援衔
     */
    @PreAuthorize("@ss.hasPermi('fireRescueRank:fireRescueRank:remove')")
    @Log(title = "消防救援衔", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rescueRankIds}")
    public AjaxResult remove(@PathVariable Long[] rescueRankIds)
    {
        return toAjax(ifmFireRescueRankService.deleteIfmFireRescueRankByRescueRankIds(rescueRankIds));
    }
}
